package com.menu;

import java.util.List;

@SuppressWarnings(value = { "unchecked" })
public class MenuItem
{
    private String index;
    private String name;
    private List childMenuItems;

	public String getIndex()
	{
		return index;
	}
	public void setIndex(String index)
	{
		this.index = index;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public List getChildMenuItems()
	{
		return childMenuItems;
	}
	public void setChildMenuItems(List childMenuItems)
	{
		this.childMenuItems = childMenuItems;
	}
	
	//add child menu
	public void addChildMenuItem(ChildMenuItem child)
	{
		childMenuItems.add(child);
	}
	
    public void removeChildItem(int index)
    {
        for (int idx = 1; idx <= childMenuItems.size(); idx++) {
            ChildMenuItem child = (ChildMenuItem) childMenuItems.get(idx);
            if(child.getIndex().equals(String.valueOf(index))){
                childMenuItems.remove(idx);
                break;
            }
        }
    }
    
}

